home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11536 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  931 b 

  1. From: _GOYRA_@msn.com (David Byrden)
  2. Subject: RE: Compiler unable to comprehend template for "<<" operator.  What's wrong???
  3. Date: 15 Mar 96 04:50:34 -0800
  4. References: <4hto1l$bvl@newshost.lanl.gov>
  5. Message-ID: <00001a81+0000ad52@msn.com>
  6. Path: news.msn.com!msn.com
  7. Newsgroups: comp.lang.c++
  8. Organization: The Microsoft Network (msn.com)
  9.  
  10.  
  11. Martin;
  12.  
  13.  
  14. >>   template<class Type>
  15.       class vector {
  16.          Type *v;
  17.          int   size;
  18.          friend ostream &operator<<(ostream &, vector<Type> &);
  19.       };
  20.  
  21.    template<class Type>
  22.       ostream &operator<<(ostream &ostr, vector<Type> &vec) {
  23.       }
  24.  
  25. >>Apparently the compiler doesn't know how to use the template for
  26. >>operator<< to instantiate the << operator for a vector<float>.  WHAT'S
  27. >>WRONG HERE???  I've tried several minor variations to the above code,
  28.  
  29.  
  30.     You're doing nothing wrong. Try writing the friend function inline 
  31. within the class declaration?
  32.  
  33.                         David
  34.